//
//  ZhiWeiDetailPageVC.m
//  EnterpriseEdition
//
//  Created by ypj on 2021/10/12.
//

#import "ZhiWeiDetailPageVC.h"
#import "ZhiWeiDetailMiaoShuCell.h"
#import "PositionCell.h"                //职位cell

@interface ZhiWeiDetailPageVC ()<UITableViewDelegate, UITableViewDataSource, DZNEmptyDataSetSource,  DZNEmptyDataSetDelegate>
@property (nonatomic, strong) UITableView    *tableView;
@property (nonatomic, strong) NSMutableArray *dataAry;
@property (nonatomic, strong) UITextView *contentTV;

@end

@implementation ZhiWeiDetailPageVC
-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
   
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = White_Color;
    [self layoutCustomNav:self.view title:@"职位详情"];
    [self dataAry];
    [self getZhiWeiDetail];
    self.dataAry = [NSMutableArray arrayWithArray:@[@"职位名称", @"薪资范围", @"联系人", @"联系电话", @"负责人", @"司机性质"]];
    self.userInfo = [YLUserMgr fetchUser];
    [self createTableView];
}

-(void)createTableView{
    self.tableView = [[UITableView  alloc] initWithFrame:CGRectMake(0, kViewTopHeight, ScreenWidth, 330)];
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    self.tableView.emptyDataSetSource = self;
    self.tableView.emptyDataSetDelegate = self;
    _tableView.scrollEnabled = NO;
    self.tableView.estimatedRowHeight = 0;
    self.tableView.estimatedSectionFooterHeight = 0;
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    [self.view addSubview:self.tableView];
    [_tableView registerClass:[PositionCell class] forCellReuseIdentifier:@"cell"];
    
    UILabel *driverDescribeLB = [[UILabel alloc] initWithFrame:CGRectMake(20, _tableView.Y_height + 20, 100, 18)];
    driverDescribeLB.text = @"详情描述";
    driverDescribeLB.font = [UIFont systemFontOfSize:15];
    driverDescribeLB.textColor = Color333;
    [self.view addSubview:driverDescribeLB];
    
    self.contentTV = [[UITextView alloc] initWithFrame:CGRectMake(20, driverDescribeLB.Y_height + 15, ScreenWidth - 40, ScreenHeight - driverDescribeLB.Y_height - 15 - 20)];
    _contentTV.font = [UIFont systemFontOfSize:14];
    _contentTV.editable = NO;
    _contentTV.textColor = ColorWithAAAAAA;
    [self.view addSubview:_contentTV];
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return self.dataAry.count;
   
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
     return 1;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    PositionCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    cell.leftLB.text = _dataAry[indexPath.row];
    if (indexPath.row == 0) {
        cell.rightLB.text = self.model.jobName;             //职位
    } else if (indexPath.row == 1){
        cell.rightLB.text = [NSString stringWithFormat:@"%@元",self.model.salaryRange];         //薪资范围
        cell.rightLB.textColor = colorWithFF0000;
    } else if (indexPath.row == 2){
        cell.rightLB.text = self.model.userLiaisonName;     //联系人
    } else if (indexPath.row == 3){
        cell.rightLB.textColor = Color333;
        cell.rightLB.text = self.model.userLiaisonPhone;    //电话
    } else if (indexPath.row == 4){
        cell.rightLB.text = self.model.userNameNickName;    //负责人
        cell.rightLB.textColor = Color333;
    } else {
        cell.rightLB.text = self.model.driverNature;
        cell.rightLB.textColor = Color333;
    }
    cell.lineView.backgroundColor = ColorWithE7EDF2;
        return cell;
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 50;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{

}

#pragma mark ----------------<#note#>----------------
- (NSMutableArray *)dataAry {
    if (!_dataAry) {
        self.dataAry = [@[] mutableCopy];
    }
    return _dataAry;
}

///获取职位详情
-(void)getZhiWeiDetail{
    WEAKSELF
    NSString *url = [NSString stringWithFormat:@"%@?id=%@",Job_Detail_Url,self.model.ID];

    [MSNetworkManager postRevertUrl:url params:@{} success:^(id  _Nonnull paginationObj, id  _Nonnull resonseObj, BOOL isSuccess, NSString * _Nonnull message) {
        if (isSuccess){
            self.model = [ZhiWeiGuanLiModel mj_objectWithKeyValues:resonseObj];
            weakSelf.contentTV.text = weakSelf.model.remarks;
            [weakSelf.tableView reloadData];
        }
    } failure:^(NSUInteger code, NSString * _Nonnull message) {
    } withShowHud:YES];

}

@end
